

/**
 * 创建entity box
 */
import Entity from '../Entity'

export default class Box extends Entity{
  /**
   * 创建一个box实体对象
   * @param {Cartesian3} position 
   * @param {Object} options 
   */
  constructor(positions , options = {}) {
    super()
    this.delegate = new Cesium.Entity({ box : {} })
    this._style = {
      ...options
    }
    this._type = 'box'
    this._positions = positions
    this._dimensions = options.dimensions
    this.mounted()
  }
  
  /**
   * 初始化对象属性
   */
  
  mounted(){
    this.style = this._style
    this.dimensions = this._dimensions
    this.positions = this._positions
  }

  /** 
   * @param {*} style box的样式
   * @returns 
   */

  setStyle(style){
    if(!style) return
    delete style['position']
    Object.assign(this._style , {...style})
    Object.assign(this.delegate.box , {...this._style})
  }

  get style (){
    return this._style
  }

  set style(val){
    Object.assign(this._style , {...val})
    Object.assign(this.delegate.box , {...this._style})
  }

  /**
   * 获取位置信息
   */

  get positions(){
    return this._positions
  }
  /**
   * 设置位置信息
   */
  set positions(positions){
    this._positions= positions
    this.delegate.position = this._positions
  }
  /**
   * 获取长宽高
   */

  get dimensions(){
    return this._dimensions
  }
  /**
   * 设置长宽高
   */
  
  set dimensions(val){
    this._dimensions = val
    this.delegate.box.dimensions = this._dimensions
  }
}
